<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>关键字申请管理</title>
<%@ include file="head.jsp" %>
<link rel="stylesheet" type="text/css" href="static/css/keywordmanage.css" />
<script type="text/javascript">
	$(function() {
		$("#keywords_manage_dg")
				.datagrid(
						{
							url : "keywords/list",
							columns : [ [
									{
										field : 'keywords',
										title : '关键词'
									},
									{
										field : 'customname',
										title : '客户名称'
									},
									{
										field : 'agentname',
										title : '代理商'										
									},
									{field:'serviceyears',title:'申请年限'},
									{
										field : 'regdatetime',
										title : '申请日期',
										align : 'center',
										formatter : function(value) {
											return formatDateTime(value);
										}										
									},
									{field:'regpassdatetime',title:'到期日期',
										formatter : function(value) {
											return formatDateTime(value);
										}		
									},
									{field:'ispass',title:'申请到期状态',
										formatter : function(value, row, index) {
											switch (value) {
											case 0:
												return "未过期";
												break;
											case 1:
												return "预注册过期";
												break;
											case 2:
												return "过期";
												break;
											}
										},	
										styler : function(value, row, index) {
											if (value == 0) {
												return 'color:green;';
											}else{
												return 'color:red;';
											}
										}
									},
									{field:'checkstatus',title:'审核状态',
										formatter : function(value, row, index) {
											switch (value) {
											case 0:
												return "已申请";
												break;
											case 1:
												return "审核中";
												break;
											case 2:
												return "已通过";
												break;
											case 3:
												return "未通过";
												break;										
											}
										},	
										styler : function(value, row, index) {
											if (value == 3) {
												return 'color:red;';
											}else{
												return 'color:green;';
											}
										}	
									},
									{field:'isuse',title:'使用状态',
										formatter : function(value, row, index) {
											switch (value) {
											case 0:
												return "未使用";
												break;
											case 1:
												return "已使用";
												break;
																				
											}
										},	
										styler : function(value, row, index) {
											if (value == 0) {
												return 'color:red;';
											}else{
												return 'color:green;';
											}
										}		
									},
									{field:'openapp',title:'APP开通状态',
										formatter : function(value, row, index) {
											switch (value) {											
											case 1:
												return "已开通";
												break;
											default:
												return "未开通";
												break;								
											}
										},	
										styler : function(value, row, index) {
											if (value == 1) {
												return 'color:green;';
											}else{
												return 'color:red;';
											}
										}		
									},
									{title:'操作',field:'id',
										formatter : function(value, row, index) {
											var use = row.isuse;
											var status = row.checkstatus;
											var app = row.openapp;
											var keyword = row.keywords;
											if(use==1){
												if(status==2){
													if(app!=1){
														return '<a href="javascript:openapp('+value+',\''+keyword+'\');"  class="openapp">开通APP</a>  <a href="javascript:xufei('+value+',\''+keyword+'\');"  class="xufei">续费</a>';
													}
													return '<a href="javascript:xufei('+value+',\''+keyword+'\');"  class="xufei">续费</a>';
												}else if(row.ispass==2){
													return '<a href="javascript:xufei('+value+',\''+keyword+'\');"  class="xufei">续费</a>  <a href="javascript:deletekeyword('+value+',\''+keyword+'\');"  class="deletekeyword">删除</a>';
												}else if(status==3){
													return '<a href="javascript:deletekeyword('+value+',\''+keyword+'\');"  class="deletekeyword">删除</a>';
												}else{
													return '<font color="#ccc">无操作</font>';
												}
											}else{
												return '<font color="#ccc">无操作</font>';
											}
										}								
									}] ],
							fitColumns : true,//自适应宽度 
							striped : true,//列表是否有间隔底色
							resizable : true,//列尺寸可调节
							singleSelect : true,
							loadMsg : '正在努力加载中..',
							rownumbers : true, //行前显示行号
							idField : 'id', //指定选中时返回的维度字段名，如id

							pagination : true,//是否显示分页
							pageSize : 10,//每页条数 
							pageList : [ 10,20,30 ]
						});
		
		$("a.xufei").linkbutton();
		$("a.deletekeyword").linkbutton();
		$("a.openapp").linkbutton();
	});
//搜索方法
function search_keywords(){
	var keywords = {keywords:$('#keywords').val()};
	$('#keywords_manage_dg').datagrid('options').queryParams = keywords;  	   
    $("#keywords_manage_dg").datagrid('reload');  
}
</script>
</head>
<body>
<div class="easyui-panel" data-options="title:'查询',width:'100%',height:100,collapsible:true">
    <form id="keywords_search_form" action="">
        <table class="searchTb">
            <tr>
                <th>关键词：</th>
                <td><input type="text" id="keywords" name="keywords" /> </td>
                <td>
                    &nbsp;<a href="javascript:search_keywords();" class="easyui-linkbutton m10" title="查询" data-options="iconCls:'icon-search'">查询</a>
                </td>
            </tr>
        </table>
    </form>
</div>
<table id="keywords_manage_dg"></table>
<div id="formbox"></div>
<script type="text/javascript" src="static/js/keywords_manage.js"></script>
</body>
</html>